import axiosHttp from "../../http"

function userInfo() {
  return axiosHttp.post("/userInfo") //这里的  '/userInfo'  是具体的接口后面的名称  例如:http://127.0.0.1/api/userInfo
}
// 检测登录成功
function indexTest() {
  return axiosHttp({
    url: "/index/page1",
    method: "get",
  }) //这里的  '/login'  是具体的接口后面的名称  例如:http://127.0.0.1/api/login
}

// 个人资料修改
async function personalData(data) {
  return await axiosHttp({
    url: "/my/personaldata",
    method: "post",
    data,
  }).then((res) => {
    // console.log(res)
    return res
  })
}

// 个人头像修改
async function headImgData(data) {
  return await axiosHttp({
    url: "/my/headImgData",
    method: "post",
    data,
  }).then((res) => {
    // console.log(res)
    return res
  })
}

// 商品图片上传
async function shopImgData(data) {
  return await axiosHttp({
    url: "/my/uploadpics",
    method: "post",
    data,
  }).then((res) => {
    // console.log(res)
    return res
  })
}

// 用户身份认证
async function userAttestation(data) {
  return await axiosHttp({
    url: "/my/userattestation",
    method: "post",
    data,
  }).then((res) => {
    // console.log(res)
    return res
  })
}

// 获取用户地址列表
async function myAddressList(data) {
  return await axiosHttp({
    url: "/my/addresslist",
    method: "get",
    data,
  }).then((res) => {
    // console.log(res)
    return res
  })
}

// 增加用户地址
async function userAddAddress(data) {
  return await axiosHttp({
    url: "/my/useraddaddress",
    method: "post",
    data,
  }).then((res) => {
    // console.log(res)
    return res
  })
}

// 获取人脸access_token
async function userFace(data) {
  return await axiosHttp({
    url: "/my/userface",
    method: "get",
    data,
  }).then((res) => {
    console.log(res)
    return res
  })
}

// 注册人脸
async function registerUserFace(data) {
  return await axiosHttp({
    url: "/my/registeruserface",
    method: "post",
    // headers: {
    //   "Content-Type": "application/json", //改这里就好了
    // },
    data,
  }).then((res) => {
    console.log(res)
    return res
  })
}

// 人脸登录
async function userFaceLogin(data) {
  return await axiosHttp({
    url: "/my/userfacelogin",
    method: "post",
    // headers: {
    //   "Content-Type": "application/json", //改这里就好了
    // },
    data,
  }).then((res) => {
    console.log(res)
    return res
  })
}

// 是否校园认证
async function userIsCheck(data) {
  return await axiosHttp({
    url: "/my/ischeckuser",
    method: "get",
    data,
  }).then((res) => {
    console.log(res)
    return res
  })
}

// 反馈
async function feedBack(data) {
  return await axiosHttp({
    url: "/my/feedback",
    method: "post",

    data,
  }).then((res) => {
    // console.log(res)
    return res
  })
}

// 获取订单列表
async function getOrderNum(data) {
  return await axiosHttp({
    url: "/my/getordernum",
    method: "get",

    data,
  }).then((res) => {
    // console.log(res)
    return res
  })
}

export default {
  userInfo,
  indexTest,
  personalData,
  headImgData,
  shopImgData,
  userAttestation,
  myAddressList,
  userAddAddress,
  userFace,
  registerUserFace,
  userIsCheck,
  feedBack,
  userFaceLogin,
  getOrderNum,
}
